package com.breaktian.assemble.webview;

import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;

/**
 * Created by tiankeke on 2017/5/31.
 */

public class BaseWebView extends WebView {
    public final static String JS_INTERFACE_NAME = "JsInterface";
    public BaseWebView(Context context) {
        super(context);
        init();
    }


    public BaseWebView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public BaseWebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }


    private void init() {
        WebViewHelper.init(this);
        addJsInterface(new WebViewJsCallback());
    }

    public void addJsInterface(WebViewJsCallback jsCallback) {
        addJavascriptInterface(jsCallback, JS_INTERFACE_NAME);
    }

    public void removeJsInterface() {
        removeJavascriptInterface(JS_INTERFACE_NAME);
    }


}
